# Verify bin folder exists

if ((test-path ..\bin) -eq $false)
{
	mkdir ..\bin | out-null
}

$binFolder = (resolve-path ..\bin)

# Create EmptyVD

if ((test-path ..\bin\EmptyVD) -eq $false)
{
	mkdir ..\bin\EmptyVD | out-null
}


# Deploy Contoso website
$contosoWebSiteLocation = (resolve-path "..\solution\Contoso\Contoso.WebSite")  
xcopy  $contosoWebSiteLocation $binFolder\Contoso.WebSite /E /Y /R /Q /I /EXCLUDE:.\tools\xcopyexcludes.txt | out-null
icacls $contosoWebSiteLocation /grant "IUSR:(F,WD)" /T 
icacls $contosoWebSiteLocation /grant "NETWORKSERVICE:(F,WD)" /T
icacls $contosoWebSiteLocation /grant "Everyone:(F,WD)" /T


# Deploy Fabrikam website
$fabrikamWebSiteLocation = (resolve-path "..\solution\Fabrikam\Fabrikam.WebSite")  
xcopy  $fabrikamWebSiteLocation $binFolder\Fabrikam.WebSite /E /Y /R /Q /I /EXCLUDE:.\tools\xcopyexcludes.txt | out-null
icacls $fabrikamWebSiteLocation /grant "IUSR:(F,WD)" /T 
icacls $fabrikamWebSiteLocation /grant "NETWORKSERVICE:(F,WD)" /T
icacls $fabrikamWebSiteLocation /grant "Everyone:(F,WD)" /T

# Deploy Litware website
$litwareWebSiteLocation = (resolve-path "..\solution\LitwareHR\Litware.WebSite")  
xcopy $litwareWebSiteLocation $binFolder\Litware.WebSite /E /Y /R /Q /I /EXCLUDE:.\tools\xcopyexcludes.txt | out-null
icacls $litwareWebSiteLocation /grant "IUSR:(F,WD)" /T 
icacls $litwareWebSiteLocation /grant "NETWORKSERVICE:(F,WD)" /T
icacls $litwareWebSiteLocation /grant "Everyone:(F,WD)" /T

# Deploy Litware Authentication Services Host
$litwareAuthenticationServiceHost = (resolve-path "..\solution\LitwareHR\LitwareHR.Authentication.SvcHost")  
xcopy $litwareAuthenticationServiceHost $binFolder\LitwareHR.Authentication.SvcHost /E /Y /R /Q /I /EXCLUDE:.\tools\xcopyexcludes.txt | out-null
icacls $litwareAuthenticationServiceHost /grant "IUSR:(F,WD)" /T 
icacls $litwareAuthenticationServiceHost /grant "NETWORKSERVICE:(F,WD)" /T
icacls $litwareAuthenticationServiceHost /grant "Everyone:(F,WD)" /T

# Deploy Litware Authorization Services Host
$litwareAuthorizationServiceHost = (resolve-path "..\solution\LitwareHR\LitwareHR.Authorization.SvcHost")  
xcopy $litwareAuthorizationServiceHost $binFolder\LitwareHR.Authorization.SvcHost /E /Y /R /Q /I /EXCLUDE:.\tools\xcopyexcludes.txt | out-null
icacls $litwareAuthorizationServiceHost /grant "IUSR:(F,WD)" /T 
icacls $litwareAuthorizationServiceHost /grant "NETWORKSERVICE:(F,WD)" /T
icacls $litwareAuthorizationServiceHost /grant "Everyone:(F,WD)" /T


# Deploy Litware Services Secure Host
$litwareSecureHost = (resolve-path "..\solution\LitwareHR\LitwareHR.Portfolio.SecureHost")  
xcopy $litwareSecureHost $binFolder\LitwareHR.Portfolio.SecureHost /E /Y /R /Q /I /EXCLUDE:.\tools\xcopyexcludes.txt | out-null
icacls $litwareSecureHost /grant "IUSR:(F,WD)" /T 
icacls $litwareSecureHost /grant "NETWORKSERVICE:(F,WD)" /T
icacls $litwareSecureHost /grant "Everyone:(F,WD)" /T

# Deploy Litware Services Secure Host
$litwareUnSecureHost = (resolve-path "..\solution\LitwareHR\LitwareHR.Portfolio.UnSecureHost")  
xcopy $litwareUnSecureHost $binFolder\LitwareHR.Portfolio.UnSecureHost /E /Y /R /Q /I /EXCLUDE:.\tools\xcopyexcludes.txt | out-null
icacls $litwareUnSecureHost /grant "IUSR:(F,WD)" /T 
icacls $litwareUnSecureHost /grant "NETWORKSERVICE:(F,WD)" /T
icacls $litwareUnSecureHost /grant "Everyone:(F,WD)" /T

# Deploy Public Application Website
$litwarePublicApp = (resolve-path "..\solution\LitwareHR\LitwareHR.PublicApp.WebUX")  
xcopy $litwarePublicApp $binFolder\LitwareHR.PublicApp.WebUX /E /Y /R /Q /I /EXCLUDE:.\tools\xcopyexcludes.txt | out-null
icacls $litwarePublicApp /grant "IUSR:(F,WD)" /T 
icacls $litwarePublicApp /grant "NETWORKSERVICE:(F,WD)" /T
icacls $litwarePublicApp /grant "Everyone:(F,WD)" /T

# Deploy Private Application Website
$litwarePrivateApp = (resolve-path "..\solution\LitwareHR\LitwareHR.PrivateApp.WebUX") 
xcopy $litwarePrivateApp $binFolder\LitwareHR.PrivateApp.WebUX /E /Y /R /Q /I /EXCLUDE:.\tools\xcopyexcludes.txt | out-null
icacls $litwarePrivateApp /grant "IUSR:(F,WD)" /T 
icacls $litwarePrivateApp /grant "NETWORKSERVICE:(F,WD)" /T
icacls $litwarePrivateApp /grant "Everyone:(F,WD)" /T